package com.zeus.web;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.zeus.web.converters.PostRequestDecryptConverters;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter;

/**
 * @author magic
 * @date 2018/9/5/005 10:40
 * @version 1.0
 * Description WebConfiguratorAutoConfiguration
 */
@AutoConfigureBefore(HttpMessageConvertersAutoConfiguration.class)
@Configuration
public class WebConfiguratorAutoConfiguration {

    @Bean
    @ConditionalOnProperty(prefix = "decrypt", name = "enabled", havingValue = "true",matchIfMissing = true)
    public AbstractJackson2HttpMessageConverter postRequestDecryptConverters(ObjectMapper objectMapper){
        return new PostRequestDecryptConverters(objectMapper);
    }
}
